﻿<UserControl x:Class="Sautom.Modules.Client.Views.ClientDetails"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:res="clr-namespace:Sautom.I18N;assembly=Sautom.I18N" xmlns:l="clr-namespace:Sautom.ClientComunication.Converters;assembly=Sautom.ClientComunication"
             xmlns:Views="clr-namespace:Sautom.Modules.Client.Views"
             xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism"
             xmlns:Controls="clr-namespace:Sautom.Modules.Client.Controls" mc:Ignorable="d" 
             d:DesignHeight="605" d:DesignWidth="984" >

    <UserControl.Resources>
        <l:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
        <l:IsGroupTypeToTextConverter x:Key="IsGroupTypeToTextConverter" />
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground" Value="#FF5C26D4" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150*" />
            <ColumnDefinition Width="150*" />
            <ColumnDefinition Width="300*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="180*" />
            <RowDefinition Height="80*" />
        </Grid.RowDefinitions>
        <Menu Grid.ColumnSpan="3">
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.BackToClientsBtn}}" Command="{Binding BackCommand}" />
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.EditClientsBtn}}" Command="{Binding EditCommand}" />
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.AddOrderForClientBtn}}" Command="{Binding AddOrderCommand}" />
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.AirlineTicketViewBtn}}" Command="{Binding AirlineTicketCommand}" />
            <MenuItem Header="{Binding Source={x:Static res:ClientResources.ContractViewBtn}}" Command="{Binding ContractCommand}" />
        </Menu>
        <Border Grid.Row="1" BorderBrush="Azure" BorderThickness="3" Grid.ColumnSpan="2">
            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
                <Label Content="{Binding Source={x:Static res:ClientResources.NameRuLabel}}" />
                <TextBlock Text="{Binding NameRu}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.NameEnLabel}}" />
                <TextBlock Text="{Binding NameLat}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.BirthDateLabel}}" />
                <TextBlock Text="{Binding BirthDate, StringFormat=d}" />

                <Label Content="{Binding Source={x:Static res:ClientResources.PersonalNumberLabel}}" />
                <TextBlock Text="{Binding PersonalNumber}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PassportInfoLabel}}" />
                <TextBlock Text="{Binding PassportInfo}" />

                <Label Content="{Binding Source={x:Static res:ClientResources.PassportByWhomLabel}}" />
                <TextBlock Text="{Binding PassportByWhom}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PassportFromDateLabel}}" />
                <TextBlock Text="{Binding PassportFromDate, StringFormat=d}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PassportByDateLabel}}" />
                <TextBlock Text="{Binding PassportByDate, StringFormat=d}" />

                <Label Content="{Binding Source={x:Static res:ClientResources.AddressLabel}}" />
                <TextBlock Text="{Binding Address}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PhoneFirstLabel}}" />
                <TextBlock Text="{Binding PhoneFirst}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.PhoneSecondLabel}}" />
                <TextBlock Text="{Binding PhoneSecond}" />                
            </StackPanel>
        </Border>
        <StackPanel Grid.Row="1" Grid.Column="1">
            <StackPanel Visibility="{Binding IsParentSection, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}">
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentNameLabel}}" />
                <TextBlock Text="{Binding ParentName}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentAddressLabel}}" />
                <TextBlock Text="{Binding ParentAddress}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentPhoneLabel}}" />
                <TextBlock Text="{Binding ParentPhone}" />
                <Label Content="{Binding Source={x:Static res:ClientResources.ParentPassportInfoLabel}}" />
                <TextBlock Text="{Binding ParentPassportInfo}" />
            </StackPanel>        	
            <Views:ClientFileList DataContext="{Binding ClinetFileListViewModel}" Margin="0,10,0,0"/>
        </StackPanel>

        <StackPanel Grid.Row="2" Grid.ColumnSpan="2">
            <TextBox Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}" MinHeight="50" TextWrapping="Wrap" AcceptsReturn="True" />
            <ListBox ItemsSource="{Binding Comments}" MaxHeight="100" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <DockPanel>
                            <TextBlock Text="{Binding Date, StringFormat=d}" Margin="0,0,15,0" />
                            <TextBlock Text="{Binding Comment}" Margin="0,0,15,0" />
                            <TextBlock Text="{Binding Manager}" Margin="0,0,15,0" />
                        </DockPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>
        <Border Grid.Row="1" Grid.Column="2" BorderBrush="Azure" BorderThickness="3">
            <StackPanel>
                <ListBox ItemsSource="{Binding Orders}" SelectedItem="{Binding SelectedOrder, Mode=TwoWay}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="60*" />
                                    <ColumnDefinition Width="60*" />
                                    <ColumnDefinition Width="60*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding IsGroupType, Converter={StaticResource IsGroupTypeToTextConverter}}" />
                                <TextBlock Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Text="{Binding StartDate, StringFormat=d}" />
                                <StackPanel Grid.Column="1" HorizontalAlignment="Left">
                                    <TextBlock Text="{Binding SchoolName}" />
                                    <TextBlock Text="{Binding CourseName}" />
                                </StackPanel>
                                <StackPanel Grid.Column="2" HorizontalAlignment="Right">
                                    <Image  Visibility="{Binding IsActive, Converter={StaticResource BoolToVisibilityConverter}}" 
                                       VerticalAlignment="Top" HorizontalAlignment="Right"  Source="..\Images\bluestar.png" Width="8" Height="8" />
                                    <TextBlock VerticalAlignment="Bottom" Text="{Binding ResponsibleManager}" />
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <Controls:OrderViewer DataContext="{Binding SelectedOrderViewModel}" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
